
pkgname=crda
pkgver=4.14
pkgrel=1
pkgdesc="Central Regulatory Domain Agent"
arch=('x86_64')
url="https://wireless.kernel.org/en/developers/Regulatory/CRDA"
license=('custom')
depends=('wireless-regdb' 'libnl' 'libgcrypt' 'systemd' 'iw')
makedepends=('python2-m2crypto')
install=crda.install
#source=("https://kernel.org/pub/software/network/crda/${pkgname}-${pkgver}.tar.xz"
source=("https://git.kernel.org/pub/scm/linux/kernel/git/mcgrof/crda.git/snapshot/${pkgname}-${pkgver}.tar.gz"
        'set-wireless-regdom'
        'libreg.patch')
md5sums=('cac7ba8de3e2e6aa46918e0c76df7d67'
         '65c93f2ff2eb1b29d9e9fa102ae2dd45'
         '067be591ddedb9572a73373c92fb4bc7')

build() {
  cd ${pkgname}-${pkgver}
  
  sed -e "s|$(Q)ldconfig||" -i Makefile
  patch -p1 -i ${srcdir}/libreg.patch
  
  make
}

package() {
  cd ${pkgname}-${pkgver}

  make DESTDIR=${pkgdir} UDEV_RULE_DIR=/usr/lib/udev/rules.d/ SBINDIR=/usr/bin/ install
 
  echo 'ACTION=="add" SUBSYSTEM=="module", DEVPATH=="/module/cfg80211", RUN+="/usr/bin/set-wireless-regdom"' >> ${pkgdir}/usr/lib/udev/rules.d/85-regulatory.rules

  install -D -m644 LICENSE ${pkgdir}/usr/share/licenses/crda/LICENSE
  install -D -m755 ../set-wireless-regdom ${pkgdir}/usr/bin/set-wireless-regdom
}

